package com.func.springsecuritydemo.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

import com.func.springsecuritydemo.service.UserDetailService;

@Configuration
@EnableWebSecurity
public class SecurityConfig  extends WebSecurityConfigurerAdapter{

	@Override
	protected void configure(AuthenticationManagerBuilder auth)
			throws Exception {
		auth.userDetailsService(new UserDetailService());
	}

	@Override
	protected void configure(HttpSecurity http) throws Exception {
		http.formLogin().
		loginPage("/login.jsp").
		loginProcessingUrl("/login").
		and().
		authorizeRequests().
		antMatchers("/css/**").anonymous().
		antMatchers("/img/**").anonymous().
		antMatchers("/js/**").anonymous().
		antMatchers("/login.jsp").anonymous().
		antMatchers("/login").anonymous().
		anyRequest().authenticated();
	}
	

}
